{extends file='include/base_with_menu.tpl'}

{block name="javascript"}
<script type="text/javascript">
(function($) {
    $(function() {
        $('.normal_catagory').change(function() {
            $('.perm_catagory').val('');
        });

        $('.perm_catagory').change(function() {
            $('.normal_catagory').val('');
        });

    });
})(jQuery);
</script>
{/block}

{block name='content'}
<h3 class="blockTitle">添加帐号</h3>
<div class="layout">
<form method="post" action="/perm/user/user/add">
    <table width="100%" class="tbLayout01" cellspacing="0" cellpadding="0">
        <tr>
            <td class="textRight">姓名:</td>
            <td class="textLeft">
                <input type="text" class="txt01" name="name" />
                <span class="cGray">(2-4个汉字)</span>
            </td>
        </tr>
        <tr>
            <td class="textRight">用户名:</td>
            <td class="textLeft">
                <input type="text" class="txt01" name="username" />
                <span class="cGray">(5-8个字符)</span>
            </td>
        </tr>
        <tr>
            <td class="textRight">邮件:</td>
            <td class="textLeft">
                <input type="text" class="txt01" name="email" />
                <span class="cGray">(用户常用电子邮件地址)</span>
            </td>
        </tr>
        <tr>
            <td class="textRight">部门:</td>
            <td class="textLeft">
                <select name="department_id">
                {foreach $department_info as $info}
                    <option value="{$info.id}">{$info.name|escape}</option>
                {/foreach}
                </select>
            </td>
        </tr>
        <tr>
            <td class="textRight">权限:</td>
            <td class="textLeft">
            {foreach $role_dict as $catagory_id => $info}
                {if $catagory_id == $perm_catagory_id}
                    {continue}
                {/if}
                {$catagory_dict[$catagory_id]}权限:
                <select class="normal_catagory" name="user_role[]">
                    <option value="">--请选择--</option>
                {foreach $info as $role}
                    <option value="{$role.id}">{$role.title|escape}</option>
                {/foreach}
                </select>
                <br /><br />
            {/foreach}
            {if $SESSION->is_master()}
                管理权限:
                <select class="perm_catagory" name="user_role[]">
                    <option value="">--请选择--</option>
                    {foreach $role_dict[$perm_catagory_id] as $role}
                    <option value="{$role.id}">{$role.title|escape}</option>
                    {/foreach}
                </select>
                <br />
                <span class="cGray">(设置管理权限后，上面的权限设置失效；同样，设置上面的权限后，管理权限失效)</span>
            {/if}
            </td>
        </tr>
        <tr>
            <td class="textRight">&nbsp;</td>
            <td class="textLeft">
                <input type="submit" value="添加" />&nbsp;&nbsp;&nbsp;
                <input type="button" value="取消" onclick="javascript:window.history.back();" />
            </td>
        </tr>
    </table>
    <input type="hidden" name="{$token_name}" value="{$token_hash}" />
    <input type="hidden" name="return_url" value="{$return_url|default:''}" />
</form>
</div>
{/block}
